# !/usr/bin/env python3
# -*- coding:utf-8 -*-

from MOMA.MOMA_V1.uitls.bs4_v1.crawlers import Bs4_v1, bs4


class Bs4_v1_email(Bs4_v1):
    """
    爬取email
    """

    def run_core(self):
        """
        执行任务
        :return:
        """
        bs4_obj = self.get_text()
        return self.get_email(bs4_obj)

    def get_email(self, get_email_obj: bs4.element.ResultSet) -> str | None:
        """
        利用chinaz获取IP
        :param get_email_obj:
        :return:
        """
        try:
            obj = get_email_obj.find(name="tbody")
            tmp = obj.find_all('a')
            for i in tmp:
                self.url_list.append(i.get_text())
            return self.url_list
        except AttributeError as err:
            print("爬取不到email---{}".format(err))
